import Vue from 'vue'
import Vuex from 'vuex'
import { getStorage, setStorage, removeStorage } from '@/utils/storage.js'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user: getStorage('haoke'),
    cityId: getStorage('haokecity'),
    // 小区名称
    communityName: ''
  },
  mutations: {
    // 添加本地token
    infoSetStorage (state, payload) {
      state.user = payload
      setStorage('haoke', payload)
    },
    // 删除数据token
    infoRemoveStorage (state) {
      state.user = null
      removeStorage('haoke')
    },
    // 添加本地城市数据
    infoSetStorage2 (state, payload) {
      state.cityId = payload
      setStorage('haokecity', payload)
    },

    // 添加本地小区名
    infoSetStoragecomm (state, payload) {
      state.communityName = payload
      // setStorage('community', payload)
    }
  },
  actions: {

  },
  modules: {
  }
})
